home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_11.lha
/
6_11
/
6_11_eq1.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
856b
|
39 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
*
Assignment operator for type arbint.
/
include <arbint.h>
rbint& arbint::operator=(arbint &x) // x = y;
x.p->refcnt++;
if (--p->refcnt == 0)
{
delete p->value;
delete p;
}
p = x.p;
return *this;
/ DELETE
/ DELETE arbint& arbint::operator=(const arbint &x) // x = y;
/ DELETE {d// DELETE if (--p->refcnt == 0)
/ DELETE {
/ DELETE delete p->value;
/ DELETE delete p;
/ DELETE }
/ DELETE
/ DELETE p = new arep;
/ DELETE int nlen = x.p->length;
/ DELETE p->length = nlen;
/ DELETE p->value = new ARB_type[nlen];
/ DELETE p->refcnt = 1;
/ DELETE memcpy((char*)p->value, (char*)x.p->value,
/ DELETE nlen * sizeof(ARB_type));
/ DELETE return *this;
/ DELETE }